* Dataproc_QOL.do
* 2015.07.23
* Last update 2015.07.23: script created
* Prepares Albouy QOL data and capital stock measures for merge to project data

capture log close
set more off
timer clear 1
timer on 1
clear
set matsize 10000

local work "/DIRECTORY"

log using "`work'/logs/Dataproc_QOL_index.log", replace


* Reading data
use "`work'/data/qol/WHARTON LAND REGULATION DATA_1_24_2008.dta", clear

* Collapsing to state level without weights, as Saiz et al do in paper
collapse (mean) WRLURI, by(statename)

* Hard-coding state FIPS codes for merge
gen fips=""
replace fips = "02" if statename=="AK"
replace fips = "01" if statename=="AL"
replace fips = "05" if statename=="AR"
replace fips = "04" if statename=="AZ"
replace fips = "06" if statename=="CA"
replace fips = "08" if statename=="CO"
replace fips = "09" if statename=="CT"
replace fips = "11" if statename=="DC"
replace fips = "10" if statename=="DE"
replace fips = "12" if statename=="FL"
replace fips = "13" if statename=="GA"
replace fips = "15" if statename=="HI"
replace fips = "19" if statename=="IA"
replace fips = "16" if statename=="ID"
replace fips = "17" if statename=="IL"
replace fips = "18" if statename=="IN"
replace fips = "20" if statename=="KS"
replace fips = "21" if statename=="KY"
replace fips = "22" if statename=="LA"
replace fips = "25" if statename=="MA"
replace fips = "24" if statename=="MD"
replace fips = "23" if statename=="ME"
replace fips = "26" if statename=="MI"
replace fips = "27" if statename=="MN"
replace fips = "29" if statename=="MO"
replace fips = "28" if statename=="MS"
replace fips = "30" if statename=="MT"
replace fips = "37" if statename=="NC"
replace fips = "38" if statename=="ND"
replace fips = "31" if statename=="NE"
replace fips = "33" if statename=="NH"
replace fips = "34" if statename=="NJ"
replace fips = "35" if statename=="NM"
replace fips = "32" if statename=="NV"
replace fips = "36" if statename=="NY"
replace fips = "39" if statename=="OH"
replace fips = "40" if statename=="OK"
replace fips = "41" if statename=="OR"
replace fips = "42" if statename=="PA"
replace fips = "44" if statename=="RI"
replace fips = "45" if statename=="SC"
replace fips = "46" if statename=="SD"
replace fips = "47" if statename=="TN"
replace fips = "48" if statename=="TX"
replace fips = "49" if statename=="UT"
replace fips = "51" if statename=="VA"
replace fips = "50" if statename=="VT"
replace fips = "53" if statename=="WA"
replace fips = "55" if statename=="WI"
replace fips = "54" if statename=="WV"
replace fips = "56" if statename=="WY"
replace fips = fips + "000"
rename fips fips2

* Hard-coding 2007 capital stocks from Yamarik 2013
gen capital_stock = .
replace capital_stock = 33407 if statename=="AK"
replace capital_stock = 137904 if statename=="AL"
replace capital_stock = 84571 if statename=="AR"
replace capital_stock = 196447 if statename=="AZ"
replace capital_stock = 1562427 if statename=="CA"
replace capital_stock = 228274 if statename=="CO"
replace capital_stock = 181628 if statename=="CT"
replace capital_stock = 58996 if statename=="DC"
replace capital_stock = 33946 if statename=="DE"
replace capital_stock = 548929 if statename=="FL"
replace capital_stock = 340013 if statename=="GA"
replace capital_stock = 41981 if statename=="HI"
replace capital_stock = 102400 if statename=="IA"
replace capital_stock = 43968 if statename=="ID"
replace capital_stock = 526603 if statename=="IL"
replace capital_stock = 215458 if statename=="IN"
replace capital_stock = 107837 if statename=="KS"
replace capital_stock = 128272 if statename=="KY"
replace capital_stock = 167915 if statename=="LA"
replace capital_stock = 311015 if statename=="MA"
replace capital_stock = 212646 if statename=="MD"
replace capital_stock = 38056 if statename=="ME"
replace capital_stock = 346490 if statename=="MI"
replace capital_stock = 216963 if statename=="MN"
replace capital_stock = 194283 if statename=="MO"
replace capital_stock = 72487 if statename=="MS"
replace capital_stock = 34328 if statename=="MT"
replace capital_stock = 272213 if statename=="NC"
replace capital_stock = 26137 if statename=="ND"
replace capital_stock = 75537 if statename=="NE"
replace capital_stock = 51085 if statename=="NH"
replace capital_stock = 376628 if statename=="NJ"
replace capital_stock = 55057 if statename=="NM"
replace capital_stock = 98893 if statename=="NV"
replace capital_stock = 957048 if statename=="NY"
replace capital_stock = 379351 if statename=="OH"
replace capital_stock = 165461 if statename=="OK"
replace capital_stock = 132925 if statename=="OR"
replace capital_stock = 473980 if statename=="PA"
replace capital_stock = 35517 if statename=="RI"
replace capital_stock = 119273 if statename=="SC"
replace capital_stock = 25104 if statename=="SD"
replace capital_stock = 200786 if statename=="TN"
replace capital_stock = 1303615 if statename=="TX"
replace capital_stock = 85664 if statename=="UT"
replace capital_stock = 273303 if statename=="VA"
replace capital_stock = 21045 if statename=="VT"
replace capital_stock = 258909 if statename=="WA"
replace capital_stock = 195511 if statename=="WI"
replace capital_stock = 57521 if statename=="WV"
replace capital_stock = 35714 if statename=="WY"

* Hard-coding quality of life index from Albouy, "Are Big Cities Bad Places to Live?"
gen qol = .
replace qol = 0.014 if statename=="AK"
replace qol = -0.045 if statename=="AL"
replace qol = -0.023 if statename=="AR"
replace qol = 0.020 if statename=="AZ"
replace qol = 0.085 if statename=="CA"
replace qol = 0.065 if statename=="CO"
replace qol = 0.005 if statename=="CT"
replace qol = -0.015 if statename=="DC"
replace qol = -0.026 if statename=="DE"
replace qol = 0.020 if statename=="FL"
replace qol = -0.036 if statename=="GA"
replace qol = 0.182 if statename=="HI"
replace qol = -0.023 if statename=="IA"
replace qol = 0.007 if statename=="ID"
replace qol = -0.013 if statename=="IL"
replace qol = -0.039 if statename=="IN"
replace qol = -0.034 if statename=="KS"
replace qol = -0.044 if statename=="KY"
replace qol = -0.032 if statename=="LA"
replace qol = 0.034 if statename=="MA"
replace qol = -0.016 if statename=="MD"
replace qol = 0.027 if statename=="ME"
replace qol = -0.047 if statename=="MI"
replace qol = -0.040 if statename=="MN"
replace qol = -0.026 if statename=="MO"
replace qol = -0.053 if statename=="MS"
replace qol = 0.055 if statename=="MT"
replace qol = -0.003 if statename=="NC"
replace qol = -0.040 if statename=="ND"
replace qol = -0.014 if statename=="NE"
replace qol = 0.037 if statename=="NH"
replace qol = 0.012 if statename=="NJ"
replace qol = 0.033 if statename=="NM"
replace qol = -0.010 if statename=="NV"
replace qol = 0.003 if statename=="NY"
replace qol = -0.035 if statename=="OH"
replace qol = -0.028 if statename=="OK"
replace qol = 0.058 if statename=="OR"
replace qol = -0.039 if statename=="PA"
replace qol = 0.016 if statename=="RI"
replace qol = -0.018 if statename=="SC"
replace qol = 0.003 if statename=="SD"
replace qol = -0.029 if statename=="TN"
replace qol = -0.046 if statename=="TX"
replace qol = 0.021 if statename=="UT"
replace qol = -0.010 if statename=="VA"
replace qol = 0.071 if statename=="VT"
replace qol = 0.046 if statename=="WA"
replace qol = -0.014 if statename=="WI"
replace qol = -0.045 if statename=="WV"
replace qol = 0.014 if statename=="WY"

* Save
save "`work'/data/qol/QOL_index.dta", replace






timer off 1
timer list 1
capture log close

